import { fromJS } from 'immutable';
import getWeather from '../../../api/todoList';

export const initFetchRecommendList = (city: string) => (dispatch: Function) => {
  getWeather({ city }).then((res) => {
    dispatch({
      type: 'updateRecommendList',
      value: fromJS(res.data.weather),
    });
  }).catch((err:any) => {
    // eslint-disable-next-line no-console
    console.log(err);
  });
};

export const loadMoreRecommendList = (city: string) => (dispatch: Function) => {
  getWeather({ city }).then((res) => {
    dispatch({
      type: 'loadMoreRecommendList',
      value: fromJS(res.data.weather),
    });
  }).catch((err) => {
    // eslint-disable-next-line no-console
    console.log(err);
  });
};
